package com.dci.intellij.dbn.browser.ui;

import com.dci.intellij.dbn.browser.model.BrowserTreeModel;
import com.dci.intellij.dbn.browser.model.TabbedBrowserTreeModel;
import com.dci.intellij.dbn.common.dispose.DisposableProjectComponent;
import com.dci.intellij.dbn.connection.ConnectionHandler;
import com.dci.intellij.dbn2.utils.ReflectionUtils;
import com.intellij.util.ui.JBUI;

import javax.swing.*;

public class SpySimpleBrowserForm extends com.dci.intellij.dbn.browser.ui.SimpleBrowserForm {
    public SpySimpleBrowserForm(DisposableProjectComponent parentComponent) {
        this(parentComponent, null);
    }

    public SpySimpleBrowserForm(DisposableProjectComponent parentComponent, ConnectionHandler connectionHandler) {
        super(parentComponent, connectionHandler);

        com.dci.intellij.dbn2.browser.ui.DatabaseBrowserTree newBrowserTree =
                new com.dci.intellij.dbn2.browser.ui.DatabaseBrowserTree((BrowserTreeModel)(new TabbedBrowserTreeModel(connectionHandler)));

        ReflectionUtils.setFieldValue(this, "browserTree", newBrowserTree);

        JScrollPane browserScrollPane = (JScrollPane)ReflectionUtils.getFieldValue(this, "browserScrollPane");
        browserScrollPane.setViewportView(newBrowserTree);
        browserScrollPane.setBorder(JBUI.Borders.emptyTop(1));
        ToolTipManager.sharedInstance().registerComponent(newBrowserTree);
    }
}
